<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" :model="form" class="search_prod tl">
          <el-form-item label>
            <el-input size="small" clearable v-model="form.username" placeholder="请输入用户账号"></el-input>
          </el-form-item>
          <el-form-item label>
            <el-input size="small" clearable v-model="form.nickname" placeholder="请输入昵称"></el-input>
          </el-form-item>
          <el-form-item label>
            <el-input size="small" clearable v-model="form.shop_title" placeholder="请输入店铺名称"></el-input>
          </el-form-item>

          <el-form-item>
            <el-row class="tl">
              <el-col :span="24">
                <el-button :loading="$store.state.isLoading" size="small" class="top_weiy" type="primary" @click="searchbtn">查询</el-button>
                <el-button :loading="$store.state.isLoading" size="small" class="top_weiy" type="primary" @click="clearbtn">一键清除</el-button>
              </el-col>
            </el-row>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-table :data="shoplist.data" stripe header-row-class-name="head_color" tooltip-effect="dark" style="width: 99.9%">
      <el-table-column label="会员" min-width="100" align="center">
        <template slot-scope="scope">
          <div class="tl" style="display:flex;flex-flow:column;justify-content: center;align-items: center;">
            <img style="width:50px;height:50px" :src="$fnc.getImgUrl(scope.row.avatar)" class="user_img" />
            <span style="padding-top:0;padding-bottom:0;">{{
              scope.row.rating_cn
            }}</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="会员信息" min-width="200">
        <template slot-scope="scope">
          <div class="user_table">
            <span>用户昵称：</span>
            <small>{{ scope.row.nickname || "----" }}</small>
            <br />
            <span>店铺名称：</span>
            <small>{{ scope.row.shop_title || "----" }}</small>
            <br />
            <span>用户账号：</span>
            <small>{{ scope.row.username }}</small>
            <br />
            <span>推荐人：</span>
            <small>{{ scope.row.tid_cn }}</small>
            <br />
            <span>注册时间：</span>
            <small>{{ scope.row.created_time | getTimeFormat }}</small>
            <br />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="下级会员数" min-width="150">
        <template slot-scope="scope">
          <div class="user_table">
            直推/分销：{{ scope.row.ynumber }} / {{ scope.row.yvip }}
            <br />
            累计消费： {{ scope.row.buy | toFixedNum }}
            <br />
            累计佣金： {{ scope.row.sum_amount | toFixedNum }}
            <br />
          </div>
        </template>
      </el-table-column>

      <el-table-column label min-width="150">
        <template slot-scope="scope">
          <div class="user_table">
            订单数： {{ scope.row.s_order_num }}
            <br />
            销售额： {{ scope.row.s_sales | toFixedNum }}
            <br />
            已结算： {{ scope.row.s_settled | toFixedNum }}
            <br />
            未结算： {{ scope.row.s_unsettled | toFixedNum }}
            <br />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="120">
        <template slot-scope="scope">
          <el-button :loading="$store.state.isLoading" size="mini" @click="addShops(scope.row)">添加</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row>
      <el-col :span="24" class="table_bottom">
        <el-col :span="24" class="tr">
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage1"
              :page-sizes="[5, 10, 15, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="shoplist.all_num">
          </el-pagination>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  name: "xzShop",
  components: {},
  props: {
    show: {
      type: Boolean
    },
    types: {
      type: String
    },
    data: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data () {
    return {
      form: {},
      shoplist: {},
      currentPage1: 1,
      pageSize: 10,
      loading: false,
      searchAll: {
        is_supplier: "2",
        show: "1"
      }
    };
  },
  methods: {
    clearbtn () {
      this.currentPage1 = 1;
      this.form = {};
      this.get_shoplist(1);
    },
    searchbtn (val) {
      console.log(val);
      this.currentPage1 = 1;
      this.get_shoplist(1);
    },
    get_shoplist (page) {
      var params = this.form;
      params.page = page;
      params.page_size = this.pageSize;
      this.$api.getUser.userSupplierList(params).then(res => {
        if (res.data.code == 200) {
          this.shoplist = res.data.result;
        }
        this.loading = false;
      });
      this.loading = false;
    },
    handleSizeChange (val) {
      this.pageSize = val;
      this.currentPage1 = 1;
      this.get_shoplist(1);
    },
    handleCurrentChange (val) {
      this.get_shoplist(val);
    },
    addShops (row) {
      console.log(row);
      row.url_title = "商品选择";
      this.$emit("sendShop", row);
      this.closeDio();
    },

    closeDio () {
      this.$emit("isshow", false);
    }
  },
  watch: {
    show (old, after) {
      if (old == true) {
        this.get_shoplist(1);
      }
    }
  },
  computed: {},
  mounted () { }
};
</script>
<style lang="less" scoped>
.list_ul {
  overflow: auto;
}
.list_card {
  padding: 15px;
  cursor: pointer;
}
.card_list {
  line-height: 2;
  padding: 5px 0 0 5px;
}
.price_card {
  color: red;
}
.image {
  height: 200px;
  max-width: none;
  max-height: none;
}
</style>
